<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="/faces/templates/master_nonav.xhtml">
        <ui:define name="content">
            <p:tabView id="tv_pd" orientation="top" dynamic="true">
                <p:ajax event="tabChange" listener="#{persDataBean.onTabChange}"/>
                <p:tab id="t_o" title="Übersicht">
                    <h:panelGrid columns="2" cellpadding="5">
                        <h:outputText id="lbl_o_fn" value="Vorname: " />  
                        <h:outputText id="txt_o_fn" value="#{userBean.user.firstname}"/> 
                        <h:outputText id="lbl_o_ln" value="Nachname: " />  
                        <h:outputText id="txt_o_ln" value="#{userBean.user.lastname}"/> 
                        <h:outputText id="lbl_o_st" value="Straße: " />  
                        <h:outputText id="txt_o_st" value="#{userBean.user.address.street}"/>
                        <h:outputText id="lbl_o_n" value="Hausnummer: " />  
                        <h:outputText id="txt_o_n" value="#{userBean.user.address.number}"/> 
                        <h:outputText id="lbl_o_z" value="PLZ: " />  
                        <h:outputText id="txt_o_z" value="#{userBean.user.address.zip}"/> 
                        <h:outputText id="lbl_o_o" value="Ort: " />  
                        <h:outputText id="txt_o_o" value="#{userBean.user.address.city}"/> 
                        <h:outputText id="lbl_o_bd" value="Geburtsdatum: " />  
                        <h:outputText id="txt_o_bd" value="#{userBean.user.birthday}">
                            <f:convertDateTime pattern="dd.MM.yyyy" timeZone="GMT+2"/>
                        </h:outputText> 
                        <h:outputText id="lbl_o_m" value="E-Mail: " />  
                        <h:outputText id="txt_o_m" value="#{userBean.user.email}"/> 
                    </h:panelGrid> 
                </p:tab>
                <p:tab id="t_epd" title="Bearbeiten">
                    <h:form>
                        <h:panelGrid columns="3" cellpadding="5">  
                            <h:outputText id="lbl_fn" value="Vorname: "/>  
                            <p:inputText id="txt_fn" value="#{persDataBean.newUserData.firstname}" required="true" requiredMessage="Vorname wird benötigt"
                                         validatorMessage="Vorname ungültig">
                                <f:validateRegex pattern="[A-Za-zäöüÄÖÜß\-]+"  />
                            </p:inputText>
                            <p:message for="txt_ln" showDetail="true"/>
                            <h:outputText id="lbl_ln" value="Nachname: "/> 
                            <p:inputText id="txt_ln" value="#{persDataBean.newUserData.lastname}" required="true" requiredMessage="Nachname wird benötigt"
                                         validatorMessage="Nachname ungültig">
                                <f:validateRegex pattern="[A-Za-zäöüÄÖÜß\-]+"/>
                            </p:inputText>
                            <p:message for="txt_ln" showDetail="true"/>
                            <h:outputText id="lbl_st" value="Strasse: "/>  
                            <p:inputText id="txt_st" value="#{persDataBean.newAddressData.street}" required="true" requiredMessage="Strasse wird benötigt"/> 
                            <p:message for="txt_st" showDetail="true"/>
                            <h:outputText id="lbl_n" value="Hausnummer: "/>  
                            <p:inputText id="txt_n" value="#{persDataBean.newAddressData.number}" required="true" requiredMessage="Hausnummer wird benötigt"/> 
                            <p:message for="txt_n" showDetail="true"/>
                            <h:outputText id="lbl_z" value="Postleitzahl: "/>  
                            <p:inputText id="txt_z" value="#{persDataBean.newAddressData.zip}" required="true" requiredMessage="Postleitzahl wird benötigt"
                                         validatorMessage="Postleitzahl ungültig">
                                <f:validateRegex pattern="\d{5}"  />
                            </p:inputText>
                            <p:message for="txt_z" showDetail="true"/>
                            <h:outputText id="lbl_c" value="Ort: "/>  
                            <p:inputText id="txt_c" value="#{persDataBean.newAddressData.city}" required="true" requiredMessage="Ort wird benötigt" /> 
                            <p:message for="txt_c" showDetail="true"/>
                            <h:outputText id="lbl_bd" value="Geburtsdatum: "/>  
                            <p:calendar id="cal_bd" value="#{persDataBean.newUserData.birthday}"  required="true" requiredMessage="Geburtsdatum wird benötigt" yearRange="-120:-18" navigator="true"/>  
                            <p:message for="cal_bd" showDetail="true"/>
                            <p:commandButton id="btn_save_pd" value="#{msg.btn_save}" actionListener="#{persDataBean.saveUserData}" update=":tv_pd"/>
                            <p:commandButton id="btn_cancel_pd" value="#{msg.btn_cancel}" actionListener="#{persDataBean.cancel}" update=":tv_pd"/>
                        </h:panelGrid>
                    </h:form>
                </p:tab>
                <p:tab id="t_mail">
                    <h:form>
                        <h:panelGrid columns="3" cellpadding="5">
                            <h:outputText id="lbl_m" value="E-Mail: "/>  
                            <p:inputText id="txt_m" value="#{persDataBean.newUserData.email}" required="true" requiredMessage="E-mail wird benötigt"/>  
                            <p:message for="txt_m" showDetail="true"/>
                            <p:commandButton id="btn_save_mail" value="#{msg.btn_save}" actionListener="#{persDataBean.saveEmail}" update=":tv_pd" process="@parent"/>
                            <p:commandButton id="btn_cancel_mail" value="#{msg.btn_cancel}" actionListener="#{persDataBean.cancel}" update=":tv_pd" process="@this"/>
                        </h:panelGrid>
                    </h:form>
                </p:tab>
                <p:tab id="t_pw" title="Passwort ändern">
                    <h:form>
                        <h:panelGrid columns="3" cellpadding="5">
                            <h:outputText id="lbl_opw" value=""/>
                            <p:password id="txt_opw" binding="#{persDataBean.oldPwField}" value="#{persDataBean.oldPassword}"/>
                            <p:message for="txt_opw"/>
                            <h:outputText id="lbl_pw1" value="Passwort: "/> 
                            <p:password id="txt_pw1" value="#{persDataBean.newCredentialData.password}" match="pwd2" label="Password 1"  feedback="true" inline="false" 
                                        promptLabel=" " weakLabel="schwach" goodLabel="gut" strongLabel="stark" required="true" requiredMessage="Passwort wird benötigt" 
                                        validatorMessage="Passwörter sind ungleich"/>
                            <p:message for="txt_pw1" showDetail="true"/>
                            <h:outputText id="lbl_pw2" value="Passwort bestätigen: "/>  
                            <p:password id="txt_pw2" value="#{persDataBean.newCredentialData.password}" label="Password 2" required="true" requiredMessage="Passwort wird benötigt"/> 
                            <p:message for="txt_pw2" showDetail="true"/>
                            <p:commandButton id="btn_save_pw" value="#{msg.btn_save}" actionListener="#{persDataBean.savePassword}" update=":tv_pd" process="@parent"/>
                            <p:commandButton id="btn_cancel_pw" value="#{msg.btn_cancel}" actionListener="#{persDataBean.cancel}" update=":tv_pd" process="@this"/>
                        </h:panelGrid>
                    </h:form>
                </p:tab>
            </p:tabView>
        </ui:define>
    </ui:composition>
</html>

